package org.jeecg.modules.engine.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.engine.entity.vo.TaskVo;
import org.jeecg.modules.engine.service.ITaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class TaskController {
    @Autowired
    private ITaskService taskService;

    @GetMapping("/task/findByProcId/{procId}")
    public Result<?> findByProcId(@PathVariable String procId,
                                  TaskVo taskVo,
                                  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
                                  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize){
        Page<TaskVo> page = new Page<>(pageNo,pageSize);
        taskVo.setProcId(procId);
        IPage<TaskVo> taskVoList = taskService.selectByProcId(page,taskVo);
        return Result.ok(taskVoList);
    }
    @GetMapping("/task/findByTaskId")
    public TaskVo findByTaskId(String taskId){
        return taskService.selectByTaskId(taskId);
    }

    @GetMapping("/task/selectIdByProcAndFrame/{frameId}/{procId}")
    public String selectIdByProcAndFrame(@PathVariable String frameId,@PathVariable String procId){
        return taskService.selectIdByProcAndFrame(frameId,procId);
    }
}
